import 'dart:convert';

class BarrageModel {
  late String content;
  late String vid;
  late int priority;
  late int type;

  BarrageModel(
      {required this.content,
      required this.vid,
      required this.priority,
      required this.type});

  BarrageModel.fromJson(Map<String, dynamic> json) {
    content = json['content'];
    vid = json['vid'];
    priority = json['priority'];
    type = json['type'];
  }

  Map<String, dynamic> toJson() {
    return {'content': content, 'vid': vid, 'priority': priority, 'type': type};
  }

  static List<BarrageModel> fromJsonString(String json) {
    List<BarrageModel> list = [];
    var jsonArray = jsonDecode(json);
    if (jsonArray is List) {
      for (var item in jsonArray) {
        list.add(BarrageModel.fromJson(item));
      }
    }
    return list;
  }
}
